package com.wqm.cn.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
*
*  @author wqm
*/
public class ROLE implements Serializable {

    private static final long serialVersionUID = 1607691482836L;


    /**
    * 主键
    * 角色ID
    * isNullAble:0
    */
    private Integer ID;

    /**
    * 角色名
    * isNullAble:0
    */
    private String rOLENAME;

    /**
    * 描述
    * isNullAble:1
    */
    private String DESCRIPTION;


    public void setID(Integer ID){this.ID = ID;}

    public Integer getID(){return this.ID;}

    public void setROLENAME(String rOLENAME){this.rOLENAME = rOLENAME;}

    public String getROLENAME(){return this.rOLENAME;}

    public void setDESCRIPTION(String DESCRIPTION){this.DESCRIPTION = DESCRIPTION;}

    public String getDESCRIPTION(){return this.DESCRIPTION;}
    @Override
    public String toString() {
        return "ROLE{" +
                "ID='" + ID + '\'' +
                "rOLENAME='" + rOLENAME + '\'' +
                "DESCRIPTION='" + DESCRIPTION + '\'' +
            '}';
    }

    public static Builder Build(){return new Builder();}

    public static ConditionBuilder ConditionBuild(){return new ConditionBuilder();}

    public static UpdateBuilder UpdateBuild(){return new UpdateBuilder();}

    public static QueryBuilder QueryBuild(){return new QueryBuilder();}

    public static class UpdateBuilder {

        private ROLE set;

        private ConditionBuilder where;

        public UpdateBuilder set(ROLE set){
            this.set = set;
            return this;
        }

        public ROLE getSet(){
            return this.set;
        }

        public UpdateBuilder where(ConditionBuilder where){
            this.where = where;
            return this;
        }

        public ConditionBuilder getWhere(){
            return this.where;
        }

        public UpdateBuilder build(){
            return this;
        }
    }

    public static class QueryBuilder extends ROLE{
        /**
        * 需要返回的列
        */
        private Map<String,Object> fetchFields;

        public Map<String,Object> getFetchFields(){return this.fetchFields;}

        private List<Integer> IDList;

        public List<Integer> getIDList(){return this.IDList;}

        private Integer IDSt;

        private Integer IDEd;

        public Integer getIDSt(){return this.IDSt;}

        public Integer getIDEd(){return this.IDEd;}

        private List<String> rOLENAMEList;

        public List<String> getROLENAMEList(){return this.rOLENAMEList;}


        private List<String> fuzzyROLENAME;

        public List<String> getFuzzyROLENAME(){return this.fuzzyROLENAME;}

        private List<String> rightFuzzyROLENAME;

        public List<String> getRightFuzzyROLENAME(){return this.rightFuzzyROLENAME;}
        private List<String> DESCRIPTIONList;

        public List<String> getDESCRIPTIONList(){return this.DESCRIPTIONList;}


        private List<String> fuzzyDESCRIPTION;

        public List<String> getFuzzyDESCRIPTION(){return this.fuzzyDESCRIPTION;}

        private List<String> rightFuzzyDESCRIPTION;

        public List<String> getRightFuzzyDESCRIPTION(){return this.rightFuzzyDESCRIPTION;}
        private QueryBuilder (){
            this.fetchFields = new HashMap<>();
        }

        public QueryBuilder IDBetWeen(Integer IDSt,Integer IDEd){
            this.IDSt = IDSt;
            this.IDEd = IDEd;
            return this;
        }

        public QueryBuilder IDGreaterEqThan(Integer IDSt){
            this.IDSt = IDSt;
            return this;
        }
        public QueryBuilder IDLessEqThan(Integer IDEd){
            this.IDEd = IDEd;
            return this;
        }


        public QueryBuilder ID(Integer ID){
            setID(ID);
            return this;
        }

        public QueryBuilder IDList(Integer ... ID){
            this.IDList = solveNullList(ID);
            return this;
        }

        public QueryBuilder IDList(List<Integer> ID){
            this.IDList = ID;
            return this;
        }

        public QueryBuilder fetchID(){
            setFetchFields("fetchFields","ID");
            return this;
        }

        public QueryBuilder excludeID(){
            setFetchFields("excludeFields","ID");
            return this;
        }

        public QueryBuilder fuzzyROLENAME (List<String> fuzzyROLENAME){
            this.fuzzyROLENAME = fuzzyROLENAME;
            return this;
        }

        public QueryBuilder fuzzyROLENAME (String ... fuzzyROLENAME){
            this.fuzzyROLENAME = solveNullList(fuzzyROLENAME);
            return this;
        }

        public QueryBuilder rightFuzzyROLENAME (List<String> rightFuzzyROLENAME){
            this.rightFuzzyROLENAME = rightFuzzyROLENAME;
            return this;
        }

        public QueryBuilder rightFuzzyROLENAME (String ... rightFuzzyROLENAME){
            this.rightFuzzyROLENAME = solveNullList(rightFuzzyROLENAME);
            return this;
        }

        public QueryBuilder rOLENAME(String rOLENAME){
            setROLENAME(rOLENAME);
            return this;
        }

        public QueryBuilder rOLENAMEList(String ... rOLENAME){
            this.rOLENAMEList = solveNullList(rOLENAME);
            return this;
        }

        public QueryBuilder rOLENAMEList(List<String> rOLENAME){
            this.rOLENAMEList = rOLENAME;
            return this;
        }

        public QueryBuilder fetchROLENAME(){
            setFetchFields("fetchFields","rOLENAME");
            return this;
        }

        public QueryBuilder excludeROLENAME(){
            setFetchFields("excludeFields","rOLENAME");
            return this;
        }

        public QueryBuilder fuzzyDESCRIPTION (List<String> fuzzyDESCRIPTION){
            this.fuzzyDESCRIPTION = fuzzyDESCRIPTION;
            return this;
        }

        public QueryBuilder fuzzyDESCRIPTION (String ... fuzzyDESCRIPTION){
            this.fuzzyDESCRIPTION = solveNullList(fuzzyDESCRIPTION);
            return this;
        }

        public QueryBuilder rightFuzzyDESCRIPTION (List<String> rightFuzzyDESCRIPTION){
            this.rightFuzzyDESCRIPTION = rightFuzzyDESCRIPTION;
            return this;
        }

        public QueryBuilder rightFuzzyDESCRIPTION (String ... rightFuzzyDESCRIPTION){
            this.rightFuzzyDESCRIPTION = solveNullList(rightFuzzyDESCRIPTION);
            return this;
        }

        public QueryBuilder DESCRIPTION(String DESCRIPTION){
            setDESCRIPTION(DESCRIPTION);
            return this;
        }

        public QueryBuilder DESCRIPTIONList(String ... DESCRIPTION){
            this.DESCRIPTIONList = solveNullList(DESCRIPTION);
            return this;
        }

        public QueryBuilder DESCRIPTIONList(List<String> DESCRIPTION){
            this.DESCRIPTIONList = DESCRIPTION;
            return this;
        }

        public QueryBuilder fetchDESCRIPTION(){
            setFetchFields("fetchFields","DESCRIPTION");
            return this;
        }

        public QueryBuilder excludeDESCRIPTION(){
            setFetchFields("excludeFields","DESCRIPTION");
            return this;
        }
        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public QueryBuilder fetchAll(){
            this.fetchFields.put("AllFields",true);
            return this;
        }

        public QueryBuilder addField(String ... fields){
            List<String> list = new ArrayList<>();
            if (fields != null){
                for (String field : fields){
                    list.add(field);
                }
            }
            this.fetchFields.put("otherFields",list);
            return this;
        }
        @SuppressWarnings("unchecked")
        private void setFetchFields(String key,String val){
            Map<String,Boolean> fields= (Map<String, Boolean>) this.fetchFields.get(key);
            if (fields == null){
                fields = new HashMap<>();
            }
            fields.put(val,true);
            this.fetchFields.put(key,fields);
        }

        public ROLE build(){return this;}
    }


    public static class ConditionBuilder{
        private List<Integer> IDList;

        public List<Integer> getIDList(){return this.IDList;}

        private Integer IDSt;

        private Integer IDEd;

        public Integer getIDSt(){return this.IDSt;}

        public Integer getIDEd(){return this.IDEd;}

        private List<String> rOLENAMEList;

        public List<String> getROLENAMEList(){return this.rOLENAMEList;}


        private List<String> fuzzyROLENAME;

        public List<String> getFuzzyROLENAME(){return this.fuzzyROLENAME;}

        private List<String> rightFuzzyROLENAME;

        public List<String> getRightFuzzyROLENAME(){return this.rightFuzzyROLENAME;}
        private List<String> DESCRIPTIONList;

        public List<String> getDESCRIPTIONList(){return this.DESCRIPTIONList;}


        private List<String> fuzzyDESCRIPTION;

        public List<String> getFuzzyDESCRIPTION(){return this.fuzzyDESCRIPTION;}

        private List<String> rightFuzzyDESCRIPTION;

        public List<String> getRightFuzzyDESCRIPTION(){return this.rightFuzzyDESCRIPTION;}

        public ConditionBuilder IDBetWeen(Integer IDSt,Integer IDEd){
            this.IDSt = IDSt;
            this.IDEd = IDEd;
            return this;
        }

        public ConditionBuilder IDGreaterEqThan(Integer IDSt){
            this.IDSt = IDSt;
            return this;
        }
        public ConditionBuilder IDLessEqThan(Integer IDEd){
            this.IDEd = IDEd;
            return this;
        }


        public ConditionBuilder IDList(Integer ... ID){
            this.IDList = solveNullList(ID);
            return this;
        }

        public ConditionBuilder IDList(List<Integer> ID){
            this.IDList = ID;
            return this;
        }

        public ConditionBuilder fuzzyROLENAME (List<String> fuzzyROLENAME){
            this.fuzzyROLENAME = fuzzyROLENAME;
            return this;
        }

        public ConditionBuilder fuzzyROLENAME (String ... fuzzyROLENAME){
            this.fuzzyROLENAME = solveNullList(fuzzyROLENAME);
            return this;
        }

        public ConditionBuilder rightFuzzyROLENAME (List<String> rightFuzzyROLENAME){
            this.rightFuzzyROLENAME = rightFuzzyROLENAME;
            return this;
        }

        public ConditionBuilder rightFuzzyROLENAME (String ... rightFuzzyROLENAME){
            this.rightFuzzyROLENAME = solveNullList(rightFuzzyROLENAME);
            return this;
        }

        public ConditionBuilder rOLENAMEList(String ... rOLENAME){
            this.rOLENAMEList = solveNullList(rOLENAME);
            return this;
        }

        public ConditionBuilder rOLENAMEList(List<String> rOLENAME){
            this.rOLENAMEList = rOLENAME;
            return this;
        }

        public ConditionBuilder fuzzyDESCRIPTION (List<String> fuzzyDESCRIPTION){
            this.fuzzyDESCRIPTION = fuzzyDESCRIPTION;
            return this;
        }

        public ConditionBuilder fuzzyDESCRIPTION (String ... fuzzyDESCRIPTION){
            this.fuzzyDESCRIPTION = solveNullList(fuzzyDESCRIPTION);
            return this;
        }

        public ConditionBuilder rightFuzzyDESCRIPTION (List<String> rightFuzzyDESCRIPTION){
            this.rightFuzzyDESCRIPTION = rightFuzzyDESCRIPTION;
            return this;
        }

        public ConditionBuilder rightFuzzyDESCRIPTION (String ... rightFuzzyDESCRIPTION){
            this.rightFuzzyDESCRIPTION = solveNullList(rightFuzzyDESCRIPTION);
            return this;
        }

        public ConditionBuilder DESCRIPTIONList(String ... DESCRIPTION){
            this.DESCRIPTIONList = solveNullList(DESCRIPTION);
            return this;
        }

        public ConditionBuilder DESCRIPTIONList(List<String> DESCRIPTION){
            this.DESCRIPTIONList = DESCRIPTION;
            return this;
        }

        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public ConditionBuilder build(){return this;}
    }

    public static class Builder {

        private ROLE obj;

        public Builder(){
            this.obj = new ROLE();
        }

        public Builder ID(Integer ID){
            this.obj.setID(ID);
            return this;
        }
        public Builder rOLENAME(String rOLENAME){
            this.obj.setROLENAME(rOLENAME);
            return this;
        }
        public Builder DESCRIPTION(String DESCRIPTION){
            this.obj.setDESCRIPTION(DESCRIPTION);
            return this;
        }
        public ROLE build(){return obj;}
    }

}
